Fix a few memory leaks in the, most of them in error cases but one or two
authorLarry Ewing <lewing@gimp.org>
Mon, 19 Jul 1999 04:21:09 +0000 (04:21 +0000)
committerLarry Ewing <lewing@src.gnome.org>
Mon, 19 Jul 1999 04:21:09 +0000 (04:21 +0000)
1999-07-18  Larry Ewing  <lewing@gimp.org>

* src/io-xpm.c:
* src/io-gif.c:
* src/io-png.c:
* src/io-jpeg.c: Fix a few memory leaks in the, most of them in
error cases but one or two in the common case.  There are probably
a few small ones left.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-gif.c
gdk-pixbuf/io-jpeg.c
gdk-pixbuf/io-png.c
gdk-pixbuf/io-xpm.c

index 713e451121f40635a4733b1dfef3a34982c9fe67..1639f4409706c6b0c4220a8790e7ba6bcf62f620 100644 (file)
@@ -1,3 +1,12 @@
+1999-07-18  Larry Ewing  <lewing@gimp.org>
+
+       * src/io-xpm.c:
+       * src/io-gif.c:
+       * src/io-png.c:
+       * src/io-jpeg.c: Fix a few memory leaks in the, most of them in
+       error cases but one or two in the common case.  There are probably
+       a few small ones left.
+       
 1999-07-18  Mark Crichton  <crichton@gimp.org>
 
        * configure.in: removed version.h. 
@@ -59,4 +68,4 @@
 
 1999-07-13  Mark Crichton  <crichton@gimp.org>
 
-       * configure.in: I am a bonehead.  Added gif-lib check.
\ No newline at end of file
+       * configure.in: I am a bonehead.  Added gif-lib check.
index f07a82381ecb031739ccfb242bb319b9ecc640f5..7db7adece6e515087b0408fedde9f9c5c22239b1 100644 (file)
@@ -154,7 +154,9 @@ GdkPixBuf *image_load(FILE * f)
                tmpptr[3] = 0xFF;
            tmpptr += (is_trans ? 4 : 3);
        }
+       g_free(rows[i]);
     }
+    g_free(rows);
 
     /* Ok, now stuff the GdkPixBuf with goodies */
 
@@ -167,6 +169,7 @@ GdkPixBuf *image_load(FILE * f)
 
     /* Ok, I'm anal...shoot me */
     if (!(pixbuf->art_pixbuf)) {
+        art_free(pixels);
         g_free(pixbuf);
        return NULL;
     }
@@ -178,3 +181,5 @@ GdkPixBuf *image_load(FILE * f)
 }
 
 image_save() {}
+
+
index f8ac8139deae39b79e1eb3b4cc3dfeca9dd02949..564626242d9498ba9782d9a9789a1f909a21f8bb 100644 (file)
@@ -116,8 +116,11 @@ GdkPixBuf *image_load(FILE *f)
        /* finish off, create the pixbuf */
        pixbuf = g_new(GdkPixBuf, 1);
        pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
-       if (!(pixbuf->art_pixbuf))
+       if (!(pixbuf->art_pixbuf)) {
+               art_free(pixels);
+               g_free(pixbuf);
                return NULL;
+       }
        pixbuf->ref_count = 0;
        pixbuf->unref_func = NULL;
        
index 443010cdccfd83014de9a492e8a3cf0c4351f21d..71cce17c665c1dc4efcb635329ee7fec7173b786 100644 (file)
@@ -115,6 +115,7 @@ GdkPixBuf *image_load(FILE * f)
            for (n = 0; n < i; n++)
                g_free(rows[i]);
            g_free(rows);
+           art_free(pixels);
            png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
            return NULL;
        }
@@ -151,8 +152,12 @@ GdkPixBuf *image_load(FILE * f)
        pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
 
     /* Ok, I'm anal...shoot me */
-    if (!(pixbuf->art_pixbuf))
+    if (!(pixbuf->art_pixbuf)) {
+        art_free(pixels);
+        g_free(pixbuf);
        return NULL;
+    }
+
     pixbuf->ref_count = 0;
     pixbuf->unref_func = NULL;
 
index d4532cc997b104fdfb78087299a85ff1653ee00a..98c7532f179f24c6c513042033ba91f32be33bb0 100644 (file)
@@ -329,6 +329,7 @@ static GdkPixBuf *
        buffer = (*get_buf) (op_cmap, handle);
        if (!buffer) {
            g_warning("Can't load XPM colormap");
+           g_hash_table_destroy(color_hash);
            g_free(name_buf);
            g_free(colors);
            return NULL;
@@ -396,6 +397,9 @@ static GdkPixBuf *
            }
        }
     }
+    g_hash_table_destroy(color_hash);
+    g_free(colors);
+    g_free(name_buf);
 
     /* Ok, now stuff the GdkPixBuf with goodies */
 
@@ -407,15 +411,15 @@ static GdkPixBuf *
        pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
 
     /* Ok, I'm anal...shoot me */
-    if (!(pixbuf->art_pixbuf))
-       return NULL;
+    if (!(pixbuf->art_pixbuf)) {
+        art_free(pixels);
+       g_free(pixbuf);
+        return NULL;
+    }
+
     pixbuf->ref_count = 0;
     pixbuf->unref_func = NULL;
 
-    g_hash_table_destroy(color_hash);
-    g_free(colors);
-    g_free(name_buf);
-
     return pixbuf;
 }